﻿using System.Collections.Generic;
using System.Text;

namespace WardenMonitor
{

    public class CheatCheckPacket : Packet
    {
        public List<string> Strings { get; private set; }

        public byte Xor
        {
            get
            {
                return Data[Data.Length - 1];
            }
        }

        public int FirstCheckIndex { get; private set; }

        public CheatCheckPacket(byte[] data)
            : base(PacketDirection.Incoming, data)
        {
            ParseStrings();
        }

        private void ParseStrings()
        {
            // check opcode
            if (Data[0] != 0x02)
                return;
            Strings = new List<string> {""};
            int i = 1;
            for (; i < Data.Length; i++)
            {
                var len = Data[i];
                if (len == 0)
                    break;
                Strings.Add(Encoding.ASCII.GetString(Data, i + 1, len));
                i += len;
            }
            FirstCheckIndex = i + 1;
        }
    }

}